package cn.itcast.hotel.Web;

import cn.itcast.hotel.pojo.RequestParm;
import cn.itcast.hotel.pojo.ResponseParms;
import cn.itcast.hotel.service.IHotelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/hotel")
public class ListsearchWeb {
    @Autowired
    IHotelService iHotelService;
    @PostMapping("/list")
    public ResponseParms list(@RequestBody RequestParm parms){
        try {
            return iHotelService.search(parms);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    @PostMapping("/filters")
    public Map<String, List<String>> filters(@RequestBody RequestParm parms){
        try {
            return iHotelService.filters(parms);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @GetMapping("/suggestion")
    public List<String> suggestion(String key){
        try {
            return iHotelService.suggestion(key);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
